<?php
class My_View_Helper_Access extends Zend_View_Helper_Abstract {
    public function Access(){        
        $module = Zend_Controller_Front::getInstance()->getRequest()->getModuleName();        
        $controller = Zend_Controller_Front::getInstance()->getRequest()->getControllerName();                
        $view = Zend_Controller_Front::getInstance()->getRequest()->getActionName();     
        
        
        $p = (strtolower($module) == 'default')?1:0;
        $p += (strtolower($controller) == 'index')?1:0;
        $p += (strtolower($view) == 'index')?1:0;
        
        if($p != 3){
            $msession = new Model_Session();            
            $user = $_SESSION['username'];
            $session = $_SESSION['sessionid'];                                    
            $dbsession = $msession->fetchRow("USERNAME = '".$user."'");                        
            if($dbsession->SESSION_ID == null || $dbsession->SESSION_ID != $session)
                die('Error!!! Acceso restringido');
        }        
    }
}
?>
